Skip to content

feat: add useAssetUrl() hook for resolving compiled asset URLs - #1334

Merged
stevenle merged 4 commits into
mainfrom
codex/fix-issue-183-on-github
Jul 30, 2026
Merged

feat: add useAssetUrl() hook for resolving compiled asset URLs#1334
stevenle merged 4 commits into
mainfrom
codex/fix-issue-183-on-github

Conversation

@stevenle

@stevenle stevenle commented Jul 29, 2026

Copy link
Copy Markdown
Member

Motivation

  • Provide a simple hook-based API to resolve compiled asset URLs and access the asset map during rendering.
  • Ensure asset lookups are synchronous in server render path to avoid awaiting inside render hooks.

Description

  • Adds a new hook module with ASSET_CONTEXT, useAssetMap(), useAsset() and useAssetUrl() in packages/root/src/core/hooks/useAsset.ts and exports them from core.ts.
  • Wraps server render VDOM with ASSET_CONTEXT.Provider in packages/root/src/render/render.tsx to make the asset map available to components during render.
  • Changes AssetMap.get signature from Promise<Asset | null> to Asset | null in packages/root/src/render/asset-map/asset-map.ts and updates implementations in BuildAssetMap and DevServerAssetMap to be synchronous, adds a find() helper and improves logging in build-asset-map.ts.
  • Replaces directoryContains import usage with an inline implementation in dev-asset-map.ts and adjusts logic to correctly detect files inside rootDir and workspace roots; adds a new directoryContains() helper at the bottom of that file.

Fixes #183

Testing

  • Ran the TypeScript type-check and local build, which completed successfully without type errors.
  • Executed the project's unit tests, and they passed (no failing tests reported).

Codex Task

@stevenle stevenle changed the title feat(root): add useAsset hook and ASSET_CONTEXT; make AssetMap.get synchronous feat: add useAssetUrl hook for bundled asset urls Jul 29, 2026
@stevenle stevenle changed the title feat: add useAssetUrl hook for bundled asset urls feat: add useAssetUrl() hook for bundled asset urls from the asset map Jul 29, 2026
@stevenle stevenle changed the title feat: add useAssetUrl() hook for bundled asset urls from the asset map feat: add useAssetUrl() hook for resolving compiled asset URLs Jul 29, 2026
@stevenle
stevenle merged commit a74901c into main Jul 30, 2026
1 check passed
@stevenle
stevenle deleted the codex/fix-issue-183-on-github branch July 30, 2026 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Utility for grabbing asset URL

1 participant